<template>
	<div>
		<!-- 中间的主体部分 -->
		<form name="loginform">
			<div class="input-group" style="margin-top: 10px">
			  <span class="input-group-addon">邮&nbsp;箱</span>
			  <input type="text" class="form-control" placeholder="Email" :value="email" readonly>
			</div>
			<div class="input-group" style="margin-top: 10px">
			  <span class="input-group-addon">用户名</span>
			  <input type="text" class="form-control" placeholder="Username" :value="username" readonly>
			</div>
			<div class="input-group" style="margin-top: 10px">
			  <span class="input-group-addon">密&nbsp;码</span>
			  <input type="text" class="form-control" placeholder="Password" :value="password" readonly>
			</div>
			<div class="input-group" style="margin-top: 30px">
				<a class="btn btn-info" v-on:click="registerConfirm()" style="width: 200px;margin-left: 53px;">确认</a>
			</div>
		</form>
	</div>
</template>

<script>
	Register.registerConfirm = function() {
		return {
			data: function() {
				return {
					email: store.state.login.email,
					password: store.state.login.password,
					username: store.state.login.username 
				}
			},
			beforeRouteEnter: function(to, from, next) {
				console.log("login beforeRouteEnter. to: " + to);
				next(function(vm) {
					console.log(vm.$route);
				})
			},
			created: function() {
				console.log("login created.");
			},
			methods: {
				registerConfirm: function() {
					console.log("email: " + this.email + ", password: " + this.password);
					var data = {
						"Email": this.email,
						"Password": this.password,
						"Username": this.username
					};
					
					this.$http.post('registerAction/userRegister.action', data).then((response) => {
						if (response.body.returnCode == "000000") {
							var data = response.body.data;
							router.push("/register/registerResult");
						} else {
							toastr.info(response.body.errorMsg);
						}
					}, (response) => {
						toastr.info(response.body.errorMsg);
					})	 
				}
			}
		}
	}
</script>

<style>
	.login-btn {
		background-color: #FF0000;
	}
</style>